#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+5;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch-getchar();}
    while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
    return x*f;
}
int n,k,in[N],S;
vector<int> e[N];

bool flg;
void dfs(int u,int f,int cnt,int cntp){
    if(!flg) return;
    if(cntp==k){
        if(cnt!=1) flg=0;
        return;
    }
    for(int v:e[u]){
        if(v==f) continue;
        dfs(v,u,cnt+(S>>(v-1)&1),cntp+1);
        if(!flg) return;
    }
}

signed main(){
    freopen("life.in","r",stdin);
    freopen("life.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>k;
    for(int u,v,i=1;i<n;i++){
        cin>>u>>v;
        e[u].emplace_back(v);
        e[v].emplace_back(u);
        in[u]++,in[v]++;
    }
    bool Link=1;
    for(int i=1;i<=n;i++)
        Link&=(in[i]<=2);
    
    if(Link) cout<<"YES\n"<<k;
    else{
        int ans=0;
        for(S=0;S<(1<<n);S++){
            flg=1;
            for(int i=1;i<=n&&flg;i++)
                dfs(i,0,(S>>(i-1)&1),1);
            ans+=flg;
        }
        if(ans) cout<<"YES\n";
        else cout<<"NO\n";
        cout<<ans;
    }
    return 0;
}